<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
/**
 * App1976管理系统 beta 1.0
 * Date		2011-08
 * By		o熊小猫o
 * Email	show1990@foxmail.com
 * 后台登陆以及登陆验证
 *
 */
class Login extends CI_Controller {

	public function __construct() {
		parent::__construct();
	}


	/**
	* 后台登陆
	*
	*/
	
	//登陆
	function index()
	{
		$this->session->set_flashdata('error', "您的操作将被记录到数据库！");
		$this->load->view('admin/login');
	}
	//登陆 End


	//登陆验证
	function logining()
	{
		if ($this->input->post('submit'))
		{
			if ($this->input->post('checkbox')==1)
			{
				$user = $this->input->post('user');
				$pass = $this->input->post('pass');
				$pass = password($pass);
				$this->load->model('model');
				$array = array('user' => $user, 'pass' => $pass);
				$query = $this->model->login('admin',$array);
				if ($query>0){
					$data = array(
					'admin'	=> 'ok','name'	=> $user);
					$this->session->set_userdata($data);
					redirect(site_url('admin/home'));
				}else {
					$this->session->set_flashdata('error', "用户名或密码错误!");
					redirect(site_url('admin/login'));
				}
			}else {
				$this->session->set_flashdata('error', "登陆验证未通过!");
				redirect(site_url('admin/login'));
			}
		}else {
			$this->session->set_flashdata('error', "请勿非法提交!");
			redirect(site_url('admin/login'));
		}
	}
	//登陆验证 End

}

/* End of file login.php */
/* Location: ./application/controllers/admin/login.php */